package com.jeffse.light.stream.core.function.advance;

import com.jeffse.light.stream.core.data.collector.Collector;
import com.jeffse.light.stream.core.function.base.Function;

import java.io.Serializable;

@FunctionalInterface
public interface FlatMapFunction<P, O> extends Function, Serializable {
    /**
     * The core method of the FlatMapFunction. Takes an element from the input data set and transforms
     * it into zero, one, or more elements.
     *
     * @param value The input value.
     * @param out The collector for returning result values.
     *
     * @throws Exception This method may throw exceptions. Throwing an exception will cause the operation
     *                   to fail and may trigger recovery.
     */
    void flatMap(P value, Collector<O> out) throws Exception;
}